/**
 * 
 */
package net.cloudcodex.client.campaign.view;

import net.cloudcodex.client.widgets.VerticalTabLayoutPanel;

import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.logical.shared.HasSelectionHandlers;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.Label;
import com.google.inject.Inject;

/**
 * @author dweltz
 * 
 */
public class CampaignsViewImpl extends VerticalTabLayoutPanel implements
		CampaignsView {

	private Message message;

	@Inject
	public CampaignsViewImpl(Message message) {
		super(120, Unit.PX);
		this.message = message;

	}

	@Override
	public int addCampaignTab(IsWidget view, String name) {
		this.add(view.asWidget(), new Label(name));
		return this.getWidgetIndex(view.asWidget());
	}

	@Override
	public void refreshCampaignTabName(CampaignView view, String name) {
		int index = this.getWidgetIndex(view.asWidget());
		this.remove(view.asWidget());
		this.insert(view.asWidget(), new Label(name), index);
		this.selectTab(index);
	}

	@Override
	public void selectCampaignTab(Integer index) {
		this.selectTab(index);

	}
	
	@Override
	public HasSelectionHandlers<Integer> getCampaignTab(){
		return this ;
	}

}
